package com.mb.ext.core.util;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

//import java.util.Base64;





public class Base64Util {

    /** 解码  */
    public static byte[] decode(String encodedText){
        //final Base64.Decoder decoder = Base64.getDecoder();
        //return decoder.decode(encodedText);

        BASE64Decoder decoder = new BASE64Decoder();
        try {
            return decoder.decodeBuffer(encodedText);
        }catch (Exception es){}
        return null;
    }
    /** 编码 */
    public static String encode(byte[] data){
        //final Base64.Encoder encoder = Base64.getEncoder();
        //return encoder.encodeToString(data);
        try{
            BASE64Encoder encoder = new BASE64Encoder();

            return encoder.encode(data);
        }catch (Exception es){}
        return null;
    }
}
